package com.akkainaction.helloactor.actorselection.actor;

import akka.actor.*;

public class LookupActor extends UntypedActor {
    @Override
    public void onReceive(Object msg) {
        System.out.println(msg);
        if (msg instanceof String) {
            if ("find".equals(msg)) {
                ActorSelection as = getContext().actorSelection("/user/targetActor");
                as.tell(new Identify("A001"), getSelf());
            }
        } else if (msg instanceof ActorIdentity) {
            ActorIdentity ai = (ActorIdentity) msg;
            if ("A001".equals(ai.correlationId())) {
                ActorRef actorRef = ai.getRef();
                System.out.println(actorRef);
            }
        }
    }
}
